package Utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import android.content.Context;

import com.netease.util.date.FormatTime;
import com.netease.util.date.TimeUtil;
import com.netease.xone.R;


public class TimeFormatUtil {

    public static String getTimeFormat(Context context, long time) {
        String value = null;
        
        FormatTime formatTime = TimeUtil.getFormatTime(time);
        switch (formatTime.getType()) {
            case FormatTime.TYPE_JUST:
            case FormatTime.TYPE_SECONDS:
                value = context.getString(R.string.time_now);
                break;
            case FormatTime.TYPE_MINUTES:
                value = formatTime.getInterval() + context.getString(R.string.time_before_minutes);
                break;
            case FormatTime.TYPE_HOURS:
                value = formatTime.getInterval() + context.getString(R.string.time_before_hour);
                break;
            case FormatTime.TYPE_DAYS:
                int days = formatTime.getInterval();
                if (days <= 3) {
                    value = days + context.getString(R.string.time_before_day);
                    break;
                }
            case FormatTime.TYPE_MONTHS:
            case FormatTime.TYPE_YEARS:
                Date date = new Date(time);
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
                value = dateFormat.format(date);
                break;
        }
        
        return value;
    }

}
